﻿using CSharpDay17__API_with_Angular_.Adapters.Interfaces;
using CSharpDay17__API_with_Angular_.Data;
using CSharpDay17__API_with_Angular_.Data.Model;
using CSharpDay17__API_with_Angular_.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CSharpDay17__API_with_Angular_.Adapters.Data_Adapters
{
    public class NoteAdapter : INoteAdapter
    {
        public List<NoteViewModel> GetUserNotes(string userId)
        {
            List<NoteViewModel> notes;
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                notes = db.Notes.Where(x => x.UserId == userId && x.DateDeleted == null).Select(x => new NoteViewModel()
                {
                    Id = x.Id,
                    DateCreated = x.DateCreated,
                    DateDeleted = null,
                    Description = x.Description
                }).ToList();
            }
            return notes;
        }
    }
}